import 'dart:async';

import 'package:flutter/widgets.dart';
import 'package:library_base/base/base_app_state_page.dart';
import 'package:library_base/base/base_list_ui.dart';
import 'package:library_base/provider/base_list_controller.dart';
import 'package:library_base/utils/theme_util.dart';

abstract class BaseListState<E, I, T extends StatefulWidget, C extends BaseListController<E, I>>
    extends BaseState<T, C> with BaseListUi {
  @override
  void initState() {
    headerTextColor = ThemeUtil.getTheme().colorScheme.primary;
    footerTextColor = ThemeUtil.getTheme().colorScheme.primary;
    headerInfoColor = ThemeUtil.getTheme().colorScheme.primary;
    footerInfoColor = ThemeUtil.getTheme().colorScheme.primary;
    super.initState();
    registerStateForList(this);
  }

  @override
  void controllerOnCreate() {
    useRefresh = true;
    isCanRefresh = true;
    isCanLoad = true;
    enableControlFinishLoad = true;
    enableControlFinishRefresh = true;
    baseGetxController?.easyRefreshController = controller;
  }

  @override
  Future onRefreshCallback() async {
    // try {
    //   await baseGetxController?.requestData();
    // } catch (e) {}
    return super.onRefreshCallback();
  }

  @override
  void dispose() {
    super.dispose();
    controller.dispose();
    scrollController.dispose();
  }
}
